<?php
namespace app\admin\controller;
use think\Db;
use changpay\ChangPay;
use app\common\controller\order\Orderget;
class Zhifu extends Common
{
//    用户列表页面
    public function index()
    {
		$qudao=$this->qudao();//调用渠道数据
		$this->assign('qudao',$qudao);
		$loanStatus = ['放款中', '已拒绝', '等待银行打款','待人工审核'];
		$this->assign('loanStatus',$loanStatus);
		return $this->fetch();	
    }
	
	//	 支付列表
    public function get_list()
    {
		$Type= input('Type');//还款类型
		$pay= input('pay');//还款方式
		$sorch= input('sorch');//参数名
		$sorch_aaa=input('sorch_aaa');//参书值
		$Orderget=new Orderget();
		$TgadminID=input('TgadminID');//渠道ID
		$page = input('page');
		$limit = input('limit');
		$where=$Orderget->sorch($sorch,$sorch_aaa,$TgadminID='',$Type,$pay);
		$re=Db::table('xb_loans_paylist a')->
		field('a.caozuorenID,a.moneysheng,b.TgadminID,a.TradeNo,b.Mobile,a.AppID,a.UserID,a.OrderSn,a.Type,a.pay,d.ApplyMoney,d.AdoptMoney,d.YyFkTime,a.OrderAmount,a.CollectionAccount,a.CreateTime,b.TrueName')
		->page($page,$limit)->where($where)
		->order('a.ID','desc')
		->join('xb_mem_info b','a.UserID=b.ID','LEFT')
		->join('xb_tg_admin c','b.TgadminID=c.ID',"LEFT")
		->join('xb_loans_applylist d','a.AppID=d.ID',"LEFT")
		->select();
		foreach ($re as $k => $v) {
		//			还款类型 1部分还款2结清3豁免 4线上还款 5线上展期 6线下还款7线下展期 
			if($v['Type']=='1'){
				$re[$k]['Type']='<span style="color:gray">部分还款</span> ';
			}
			if($v['Type']=='2'){
				$re[$k]['Type']='<span style="color:#bdbd42">结清</span>';
			}
			if($v['Type']=='3'){
				$re[$k]['Type']='<span style="color:#0000FF">豁免 </span>';
			}
			if($v['Type']=='4'){
				$re[$k]['Type']='<span style="color:yellor">线上还款</span>';
			}
			if($v['Type']=='5'){
				$re[$k]['Type']='<span style="color:blue">线上展期 </span>';
			}
			if($v['Type']=='6'){
				$re[$k]['Type']='<span style="color:green">线下还款</span>';
			}
			if($v['Type']=='7'){
				$re[$k]['Type']='<span style="color:#0000FF">线下展期 </span>';
			}
//			1线下微信 2线下支付宝 3线下银联 4线上微信 5线上支付宝 6线上银联7豁免
			if($v['pay']=='1'){
				$re[$k]['pay']='<span style="color:#28004D">线下微信</span>';
			}
			if($v['pay']=='2'){
				$re[$k]['pay']='<span style="color:#0000FF">线下支付宝</span>';
			}
			if($v['pay']=='3'){
				$re[$k]['pay']='<span style="color:#00FF00">线下银联</span>';
			}
			if($v['pay']=='4'){
				$re[$k]['pay']='<span style="color:#00FFFF">线上微信</span>';
			}
			if($v['pay']=='5'){
				$re[$k]['pay']='<span style="color:#FF0000">线上支付宝</span>';
			}
			if($v['pay']=='6'){
				$re[$k]['pay']='<span style="color:#FF00FF">线上银联</span>';
			}
			if($v['pay']=='7'){
				$re[$k]['pay']='<span style="color:#0000FF ">豁免</span>';
			}
		
			$re[$k]['TgadminID']=Db::table('xb_tg_admin')->where(['ID'=>$v['TgadminID']])->value('Name');//获取渠道名称
			if($v['caozuorenID']=='0'){
				
			 $re[$k]['caozuorenID']='用户自己';//获取渠道名称
			}else{
				 $re[$k]['caozuorenID']=Db::table('xb_sys_administrator')->where(['ID'=>$v['caozuorenID']])->value('UserName');//获取渠道名称
			}
//			还款表里面的应还日期 减去6天  等于还款之前的应还日
			if($v['Type']=='5' || $v['Type']=='7'){
//				echo 22;die;
				$re[$k]['YyFkTime']=$Orderget->get_time_jian($v['YyFkTime'],'6');//获取还款类型和支付方式
			}
		}
//       p($re);die;
        $cuont=Db::table('xb_loans_paylist a')->
		field('a.TradeNo,b.Mobile,a.AppID,a.UserID,a.OrderSn,a.Type,a.pay,d.ApplyMoney,d.AdoptMoney,d.YyFkTime,a.OrderAmount,a.CollectionAccount,a.CreateTime,b.TrueName')
        ->where($where)
		->join('xb_mem_info b','a.UserID=b.ID','LEFT')
		->join('xb_tg_admin c','b.TgadminID=c.ID',"LEFT")
		->join('xb_loans_applylist d','a.AppID=d.ID',"LEFT")
		->count('a.ID');
		songsong($re,$cuont);
    }

	

}
